package day03;

import java.util.Scanner;

public class Test01 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long m = sc.nextLong();
        long p = sc.nextLong();
        long first = 0;
        for (long i = 1; i <= n; i++)
            first += f(i);
        long second = first % f(m);
        System.out.println(second % p);
    }

    static long f(long x) {
        if (x <= 0)
            return 0;
        else if (x == 1 || x == 2)
            return 1;
        else
            return f(x - 1) + f(x - 2);
    }
}  